<template>
    <div>
<h2>添加康复</h2>
<table class="table">
    <tbody>
        <tr>
            <td>项目名称</td>
            <td>
                <input type="text" v-model="data.name">
            </td>
        </tr>
        <tr>
            <td>服务时长</td>
            <td>
                <input type="text" v-model="data.timeNum">小时
           </td>
        </tr>
        <tr>
            <td>服务人数</td>
            <td>
                <input type="text" v-model="data.num">人
           </td>
        </tr>
        <tr>
            <td>佣金</td>
            <td>
                <input type="text" v-model="data.price">元
           </td>
        </tr>
        <tr>
            <td>状态</td>
            <td>
                <input type="radio" v-model="data.zhuangTai" name="zhuangTai" value="1" checked>正常
                <input type="radio" v-model="data.zhuangTai" name="zhuangTai" value="2">异常
            </td>
        </tr>
        <tr>
            <td>
                <input type="button" value="修改" @click="Add()">
                <a href="/GetKangFu">返回列表</a>
            </td>
        </tr>
    </tbody>
</table>
    </div>
</template>

<script setup lang="ts">
import { ref,onMounted } from 'vue';
import axios from 'axios';

import { useRoute } from 'vue-router';
const route=useRoute();

onMounted(()=>{
    FanTian();
})

const data=ref({  
  "id": 0,
  "name": "",
  "timeNum": 0,
  "num": 0,
  "price": 0,
  "zhuangTai": 0
})

const Add=()=>{
    axios.put("https://localhost:7182/api/KangFu/UpDateKangFu",data.value).then(res=>{
        if(res.data>0){
            alert("修改成功");
            location.href="/GetKangFu"
        }
        else{
            alert("修改失败");
        }
    })
}

const FanTian=()=>{
    var vid=route.query.id
    axios.get("https://localhost:7182/api/KangFu/GetKangFuId",{params:{id:vid}}).then(res=>{
        data.value=res.data;
    })
}

</script>

<style scoped>

</style>